//
//  AYBaseTabViewController.swift
//  iOSSinaWeb
//
//  Created by yws on 16/5/11.
//  Copyright © 2016年 yws. All rights reserved.
//

import UIKit



class AYBaseTabViewController: UITableViewController {

    var userLogin:Bool = AYUserAccountViewModel.sharedInstance.isUserLogin
    
    
    override func loadView() {
        if userLogin {
            super.loadView()
        }
        else{
            view = vistorView
            
            vistorView.delegate = self
            
            if self is AYHomeViewController {
            
                vistorView.startRotationAnimation()
            }else if self is AYMessageTableViewController {
                vistorView.setupVisitorInfo("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
            }else if self is AYDiscoveryViewController {
                vistorView.setupVisitorInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            }else if self is AYProfileViewController {
                vistorView.setupVisitorInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
            }
            
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(visitorViewDidClickRegister))
            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(visitorViewDidClickLogin))
            
        }
        
    }

    // MARK: - lazy
     lazy var vistorView: AYVisitorView = AYVisitorView()
    

}

extension AYBaseTabViewController: AYVisitorViewDelegate {
    
    
    
    func visitorViewDidClickRegister() {
        print("点击了注册")
        print(#function)
    }
    
    
    func visitorViewDidClickLogin() {
        print("点击了登陆")
        
        let oauthVC = AYOauthViewController()
        let nvVC = UINavigationController(rootViewController: oauthVC)
        //Modal跳转方法
        presentViewController(nvVC, animated: true, completion: nil)
        
    }
}